﻿using Direct.IDAL.Manager.ServiceCenter;
using DirectSell.Common.Filter;
using DirectSell.Common.Page;
using DirectSell.IBLL;
using DirectSell.Model.Manager;
using DirectSell.Model.Query;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace DirectSell.WebLayer.Areas.Manager.Controllers
{
    public class ServiceCenterAuditController : Controller
    {
        #region 依赖注入
        [Dependency("ManagerServiceAudit")]
        protected IManagerOperation _service { get; set; }

        [Dependency]
        protected IServiceCenterAuditRepository _repository { get; set; }
        #endregion

        #region 首页
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        [ManagerFilter(IsCheck =true)]
        public async Task<ActionResult> Index(BaseCondition condition)
        {
            condition.startTime = Request["startTime"];

            condition.endTime = Request["endTime"];

            var list = await _repository.QueryList(condition);

            if (Request.IsAjaxRequest())
                return PartialView("_AjaxSearchPost", list);

            return View(list);
        }
        #endregion

        #region 审核
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public async Task<ManagerRespCode> Audit(ServiceCenterAuditReq req)
        {
            return await _service.DoOperationAsync(req);
        }
        #endregion

        #region 服务中心信息
        /// <summary>
        /// 用戶信息
        /// </summary>
        /// <param name="usercode"></param>
        /// <returns></returns>
        public ActionResult CenterInfo(string usercode)
        {
            var info = _repository.QueryCenter(usercode);
            return PartialView(info);

        }
        #endregion

    }
}